#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int firstUniqChar(string s)
    {
        int ch[26] = { 0 };
        for (int i = 0; i < s.size(); i++)
        {
            ch[s[i] - 'a']++;
        }
        for (int i = 0; i < s.size(); i++)
        {
            if (ch[s[i] - 'a'] == 1)
                return i;
        }
        return -1;
    }
};